﻿namespace Oddo.Concept.Crm.Common.Presentation.Services
{
    using System.Text.RegularExpressions;
    using DevExpress.Xpf.Bars;
    using Microsoft.Practices.Unity;
    using Oddo.Concept.Crm.Common.Presentation.Infrastructure;
    using Oddo.Concept.Crm.Common.Presentation.Interfaces;

    public interface IBarService
    {
        void AddStatusBarItem(StatusBarItem item);
    }

    public class BarService : IBarService
    {
        private readonly BarManager _manager;

        public BarService(IShellView shellView)
        {
            _manager = shellView.BarManager;
        }

        public void AddStatusBarItem(StatusBarItem item)
        {
            var sbitem = new BarStaticItem()
                {
                    Content = item.Content,
                    BarItemDisplayMode = item.Image == null ? BarItemDisplayMode.Default : BarItemDisplayMode.ContentAndGlyph, 
                    Glyph = item.Image,
                    Hint = item.ToolTip,
                    Command = item.Command,
                    CommandParameter = item.CommandParameter
                };
            _manager.Items.Add(sbitem);
            _manager.StatusBar.ItemLinks.Add(sbitem);
        }
    }
}